#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 150005;
int dis[N];
int n,m;
ll a,b,ans[N];
vector<int>e[N];
queue<int>que;
int nxt[N<<3],lst[N<<3],ver[N<<3],hd[N],tot;
int vis[N];
void add(int x,int y)
{
    ++tot;
    lst[hd[x]] = tot;
    ver[tot] = y;
    //cout<<tot<<" "<<y<<"\n";
    nxt[tot] = hd[x];
    hd[x] = tot;
}
int main()
{
    //system("fc edge.out edge.ans");
    freopen("edge.in","r",stdin);
    freopen("edge.out","w",stdout);
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m>>a>>b;b = min(b,a*2);
    memset(dis,-1,sizeof(dis));
    for(int i = 1,u,v;i <= m;i++)
    {
        cin>>u>>v;
        e[u].push_back(v),e[v].push_back(u);
        add(u,v);
        add(v,u);
    }
    dis[1] = 0;
    que.push(1);
    while(!que.empty())
    {
        int u = que.front();que.pop();
        for(auto v:e[u])
        {
            if(dis[v] == -1)
            {
                dis[v] = dis[u] + 1;
                que.push(v);
            }
        }
    }
    //cout<<"====\n";
    for(int i = 2;i <= n;i++)
    {
        ans[i] = dis[i]/2*b + dis[i]%2*a;
    }
    if(b >= a)
    {
        for(int i = 2;i <= n;i++)
        {
            cout<<ans[i]<<"\n";
        }
        return 0;
    }
    memset(dis,-1,sizeof(dis));
    dis[1] = 0;
    que.push(1);
    while(!que.empty())
    {
        int u = que.front();que.pop();
        for(auto v:e[u])
        {
            vis[v] = 1;
        }
        for(auto v:e[u])
        {
            for(int i = hd[v];i;i = nxt[i])
            {
                int x = ver[i];
                //cout<<u<<" "<<v<<" "<<i<<" "<<x<<"\n";
                if(vis[x]) continue;
                //cout<<v<<" "<<x<<"\n";
                nxt[lst[i]] = nxt[i];
                lst[nxt[i]] = lst[i];
                if(i == hd[v]) hd[v] = nxt[i];
                if(dis[x] == -1) dis[x] = dis[u] + 1,que.push(x);
            }
        }
        for(auto v:e[u])
        {
            vis[v] = 0;
        }
    }
    for(int i = 2;i <= n;i++)
    {
        if(dis[i] != -1) ans[i] = min(ans[i],dis[i]*b);
        cout<<ans[i]<<"\n";
    }
    return 0;
}